<template>
  <div>
    <!--    <iframe-->
    <!--      id="iframe"-->
    <!--      src="http://14.29.79.10:8808/jc/image/common/luckysheet/index.html"-->
    <!--      style="width: 100%;height: calc(100vh - 200px)"-->
    <!--    />-->
    <div style="margin-bottom: 5px">
      <el-button size="mini" type="primary" @click="save">保存</el-button>
    </div>
  </div>
</template>

<script>
import { insertExcel } from '@/api/homePage/business'
export default {
  data() {
    return {
      url: '/tJxExcel/insertExcel' // 新增
    }
  },
  mounted() {
    // var that = this
    // this.iframe = document.getElementById('iframe')
    // this.iframe.onload = function() {
    //   // iframe加载完毕后 向html传值
    //   that.postMsg()
    // }
  },
  methods: {
    save() {
      const DATA = {
        detail: this.editor.txt.html()
      }
      insertExcel(DATA).then(res => {
        if (res.code === 0) {
        } else {
          this.$confirm(res.message, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'error'
          })
        }
      })
    },

    // 向html传值
    postMsg() {
      if (location.pathname === '/mlg-web/') { // 摩洛哥
        this.iframeURL = 'http://182.160.0.111:8808/mlg' + this.url
      } else if (location.pathname === '/jnk-web/') { // 摩洛哥-海绵
        this.iframeURL = 'http://182.160.0.111:8808/jnk' + this.url
      } else { // 其他
        this.iframeURL = this.$conUrl + this.url
      }
      const fuserId = window.sessionStorage.getItem('fuserId')
      const params = {
        // url: 'http://14.29.79.10:9530' + this.url, // 测试用
        url: this.iframeURL, // URL
        fuserId
      }
      this.iframe.contentWindow.postMessage(params, '*')
    }
  }
}
</script>
<style lang="scss" scoped>
.spread-host {
  width: 100%;
  height: 600px;
}
</style>
